package com.drako.tdgdx.logic;

import com.badlogic.gdx.graphics.GL10;
import com.drako.tdgdx.helper.GlobalHelper;
import com.drako.tdgdx.logic.creep.CreepHandler;
import com.drako.tdgdx.logic.turret.TowerHandler;

public class GameLogic implements IHazLogic,IHazRenderable{
	private Player player;
	private TowerHandler towerHandler;
	private PlayingFieldDiffusion field;
	private CreepHandler creepHandler;


	public GameLogic() {
		player = new Player(100, 10);
		towerHandler = new TowerHandler(this);
		field = new PlayingFieldDiffusion(20, 12, 9, 6);
		creepHandler =new CreepHandler(this);
	}

	@Override
	public void update() {
		towerHandler.update();
		if((GlobalHelper.ticks%30) == 0){
			creepHandler.spawnCreep(GlobalHelper.arrayToPos(0, 0));
		}
		

	}

	@Override
	public void render(GL10 gl) {
		towerHandler.render(gl);
		field.render(gl);
		
	}

	public Player getPlayer() {
		return player;
	}

	public TowerHandler getTowerHandler() {
		return towerHandler;
	}

	public PlayingFieldDiffusion getField() {
		return field;
	}


	public CreepHandler getCreepHandler() {
		return creepHandler;
	}

}
